﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

using System.Web.Services;
using Newtonsoft.Json;

namespace PropertyAppraisal.SystemManage
{
    public partial class XiTongDep : System.Web.UI.Page
    {

        private static BLL.DepartmentBll depbll = new BLL.DepartmentBll();
        protected void Page_Load(object sender, EventArgs e)
        {

        }
        private static string Serialize1(dynamic list)
        {
            return JsonConvert.SerializeObject(list);
        }
        /// <summary>
        /// 显示部门列表
        /// </summary>
        /// <returns></returns>
        [WebMethod]
        public static string showDep(string name)
        {
            var result = depbll.Show();
            if (string.IsNullOrWhiteSpace(name))
            {
                return Serialize1(result);
            }
            else
            {
                return Serialize(result.Where(n => n.department_Name.Contains(name)));
            }
        }
        
        

        /// <summary>
        /// 状态变更
        /// </summary>
        /// <returns></returns>
        [WebMethod]
        public static string Stop(int State, int department_Id)
        {
            var result = depbll.Stop(State, department_Id);
            return Serialize(result);
        }
        /// <summary>
        /// 序列化方法
        /// </summary>
        /// <param name="result"></param>
        /// <returns></returns>
        private static string Serialize(dynamic result)
        {
            return JsonConvert.SerializeObject(result);
        }

    }
}